Effective Reasoning about Effectful Traversals
نویسنده
چکیده
A recent paper by Graham Hutton and Diana Fulger (‘Reasoning about Effects: Seeing the Wood through the Trees’, Trends in Functional Programming, 2008) addresses the problem of reasoning about effectful functional programs, using a relabelling function on binary trees as a simple example. We argue that their approach is less effective than it might be, because they miss two opportunities for higher-level reasoning: abstraction from the particular kinds of effect (the choice of monad) and from the pattern of recursion (the flow of computation). We present two alternative approaches using properties of idiomatic traversals, which cleanly separate the twin concerns of the kinds of effect and the pattern of recursion.
منابع مشابه
Tools for Reasoning about Effectful Declarative Programs
In the pure functional language Haskell, nearly all side-effects that a function can produce have to be noted in its type. This includes input/output, propagation of a state, and nondeterminism. If no side-effects are noted, such a function acts like a mathematical function, i.e., mapping arguments to unique results. In that case, expressions in a program can be reasoned about like mathematical...
متن کاملBe Kind , Rewind A Modest Proposal about Traversal ( FUNCTIONAL PEARL )
A recent paper by Graham Hutton and Diana Fulger (‘Reasoning about Effects: Seeing the Wood through the Trees’, in the preproceedings of Trends in Functional Programming, 2008) addresses the problem of reasoning about effectful functional programs, introducing a relabelling function on binary trees as a representative illustration. The example is a very fruitful one, but we argue that their app...
متن کاملA Modular and Statically Typed Effectful Stack for Custom Graph Traversals
Programmers often have to implement custom graph traversals by hand as either there are no suitable text-book algorithms for their tasks, or their problems are too complex for a pure querying language that lacks modularity or static typing. Our new Scala-based graph traversal language uses an effectful stack that adapts monads and type classes. Arbitrary graph effect computations and graph proc...
متن کاملEquational Reasoning with Applicative Functors
In reasoning about effectful computations, it often suffices to focus on the effect-free parts. We present a package for automatically lifting equations to effects modelled by applicative functors. It exploits properties of the concrete functor thanks to a modular classification based on combinators. We formalise the meta theory and demonstrate the usability of our Isabelle/HOL package with two...
متن کاملDependent Type Theory of Stateful Higher-Order Functions
In this paper we investigate a logic for reasoning about programs with higher-order functions and effectful features like non-termination and state with aliasing. We propose a dependent type theory HTT (short for Hoare Type Theory), where types serve as program specifications. In case of effectful programs, the type of Hoare triples {P}x:A{Q} specifies the precondition P , the type of the retur...
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
عنوان ژورنال:
دوره شماره
صفحات -
تاریخ انتشار 2011